<!DOCTYPE html >
<html>
<head>
    <meta name="Generator" content="TPshop v1.1" />
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width">
    <title>{$tpshop_config['shop_info_store_title']}</title>
    <meta http-equiv="keywords" content="{$tpshop_config['shop_info_store_keyword']}" />
    <meta name="description" content="{$tpshop_config['shop_info_store_desc']}" />
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/public.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/index.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/onlineservice.css"/>

    <include file="Public/meta"/>
    <script type="text/javascript" src="__STATIC__/js/jquery-1.10.1.min.js"></script>
    <script src="__STATIC__/js/jweixin-1.2.0.js"></script>

    <script>
        wx.config({
            debug: false,
            appId: "{$signPackage[appId]}",
            timestamp:"{$signPackage[timestamp]}",
            nonceStr:"{$signPackage[nonceStr]}",
            signature:"{$signPackage[signature]}",
            jsApiList:[
                'getLocation',
                'scanQRCode',
            ]
        });

        wx.ready(function () {
            wx.getLocation({
                success: function (res) {
                    var latitude = res.latitude; //纬度
                    var longitude = res.longitude; //经度
//                    var sylat = '22.510816';//商友纬度
//                    var sylon = '113.398849';//商友经度
                    var sylat = '22.5354';//恒力纬度
                    var sylon = '113.397871';//恒力经度
                    var milljl = getDisance(latitude,longitude,sylat,sylon);
                    $('#juli').val(milljl);
                },
                cancel: function (res) {
                    alert('用户拒绝授权获取地理位置');
                },
                fail: function (res) {
//                    alert(JSON.stringify(res));
                }
            });


            $("#btnscan").click(function() {
//                var juli1=$("#juli").val();
//                if(!juli1){
//                    alert("正在初始化，请稍候...");return false;
//                }
                wx.scanQRCode({
                    // 默认为0，扫描结果由微信处理，1则直接返回扫描结果
                    needResult : 1,
                    desc : 'scanQRCode desc',
                    scanType: ["qrCode"],
                    success : function(res) {
                        //扫码后获取结果参数赋值给Input
                        //var url = res.resultStr;
                        var ua = navigator.userAgent.toLowerCase();
                        with(res) {
                            //var url = resultStr.scan_code.scan_result;
                            //var url = resultStr;
                            if (/iphone|ipad|ipod/.test(ua)) {
                                //var url = resultStr.scan_code.scan_result;
                                //alert(url);
                                var url = resultStr;
                            }
                            else
                            {
                                var url = resultStr;
                            }

                        }

//                        if(!url){
//                            alert("初始化不成功，请重新扫码...");return false;
//                        }


                        //alert(url.scan_result);
                        //alert(url);

                        //商品条形码，取","后面的
                        if(url.indexOf(",")>=0){
                            var tempArray = url.split(',');
                            var tempNum = tempArray[1];
                            $("#id_securityCode_input").val(tempNum);
                        }
                        else if(url.indexOf("http")>=0){
                            //跳转
                            $("#id_securityCode_input").val(url);
                            index_submit();
                        }else{
                            $("#id_securityCode_input").val(url);
                        }
                    }
                });
            });
        });


        function getDisance(lat1, lng1, lat2, lng2) {
            var radLat1 = lat1 * Math.PI / 180.0;
            var radLat2 = lat2 * Math.PI / 180.0;
            var a = radLat1 - radLat2;
            var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
            var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
            s = s * 6378137.0;//单位：米
            s = Math.round(s * 10000) / 10000.0;
            return s
        };


        function index_submit(){
            var b_juli=700;
            var l_juli=600;
            var url=$("#id_securityCode_input").val();
            var juli1=$("#juli").val();
            if(juli1>b_juli||juli1<l_juli){
                alert("超出范围，非法操作！");return false;
            }

            window.location.href=url;
//             $.ajax({
//                type : "GET",
//                url:url,
//                dataType:'json',
//                success: function(data){
//                    var s=data.status;
//                    var msg=data.msg;
//
//                    if(s==-2){
//                        alert(msg);
//                        window.location.href='/index.php/Mobile/User/order_list/';
//                        return false;
//                    }
//
//                    if(s==1){
//                        alert(msg);
//                        return false;
//                    }
//
//
//                    if(s==2){
//                        var order_id=data.order_id;
//                        alert(msg);
//                        window.location.href='/index.php/Mobile/Cart/cart4/order_id/'+order_id;
//                        return false;
//                    }
//                }
//            });

        }


        /*    function index_submit(){
         var url=$("#id_securityCode_input").val();
         //            var url='/index.php/Mobile/Index/begin_open';
         var juli1=$("#juli").val();
         if(juli1>b_juli||juli1<l_juli){
         alert("超出范围，非法操作！");return false;
         }
         $.ajax({
         type : "GET",
         url:url,
         dataType:'json',
         success: function(data){
         var s=data.status;
         var msg=data.msg;

         if(s==-2){
         alert(msg);
         window.location.href='/index.php/Mobile/User/order_list/';
         return false;
         }

         if(s==1){
         alert(msg);
         return false;
         }


         if(s==2){
         var order_id=data.order_id;
         alert(msg);
         window.location.href='/index.php/Mobile/Cart/cart4/order_id/'+order_id;
         return false;
         }


         }
         });

         }*/
    </script>
</head>
<body style="background: #fff;">

<div class="i_bg_top">
    <img src='{$user[head_pic]|default="__STATIC__/images/user68.png"}' class="i_person" />


    <div class="i_person_text">当前在线：{$on_live_num}人</div>
    <div style="display:none;">
        <a href="{:U('Mobile/Index/send_msg')}">测试</a>
    </div>

    <div id="i_btn_go">
        <form action="{:U('Mobile/index/open_test')}" method="post" id="form1" >
            <input id="juli" type="text" name="juli" />
            <input id="id_securityCode_input" type="hidden" name="wx_code" type="hidden" />
            <!--<button id="btn1"  >扫码</button>-->
            <!--<br><br>坐标：<div id="locationText"></div>-->
            <!--<a href="{:U('Mobile/index/open_test')}" class="open_men">开门 | 结算</a>-->

            <div class="onservice onservice_on" >
                <div class="oimg">
                    <a href="#"  id="btnscan"  class="btn_prev ease04" style="font-size: 16px;">
                        <img src="__STATIC__/images/open_icon.png" ><br >
                        结算 • 开门</a>
                </div>
                <div class="circles">
                    <div class="circle c-1"></div>
                    <div class="circle c-2"></div>
                    <div class="circle c-3"></div>
                </div>
            </div>


        </form>
    </div>

    <script type = "text/javascript">
        function scroll_news(){
            var firstNode = $('#message_list li');
            firstNode.eq(0).fadeOut('slow',function(){
                $(this).clone().appendTo($(this).parent()).show('slow');
                $(this).remove();
            });
        }
        setInterval('scroll_news()',4000);
    </script>
    <div class="newslist text">


        <ul id="message_list">
            <tpshop sql="select * from `__PREFIX__article` where cat_id=4 and is_open=1  order by sort asc,article_id desc" key="k3" item='v3'>
                <li> <a href="{:U('Article/detail',array('article_id'=>$v3[article_id]))}"><i class="icon iconfont icon-laba"></i>{$v3[title]}</a></li>
            </tpshop>
        </ul>
    </div>




</div>


<include file="Public/footer_nav"/>

</body>
</html>